package com.ybkj.daijia.common;

import java.util.Arrays;

/**
 * <pre>状态code-msg</pre>
 */
public enum CodeMsg {

    Fail(-1,"操作失败"),
    SUCCESS(0,"成功"),
    CODE_ERR(1,"验证码错误"),
    LOGIN_FAIL(2,"用户名或密码错误"),
    NOT_AUTHORIZED(3,"未认证"),
    TOKEN_INVALID(4,"token非法"),
    NUM_IS_NOT(33,"保留的位数不能小于0"),
    SIGN_FAILED(5,"token生成失败");


    private Integer code;
    private String msg;

     CodeMsg(Integer code, String msg){
        this.code=code;
        this.msg=msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static CodeMsg getCodeMsgByMsg(String msg) {
        return Arrays.stream(CodeMsg.values()).filter(e -> e.msg.equals(msg)).findAny().get();
    }
}
